/**
 * Copyright (c) 2007, Ashish Lijhara
 * All rights reserved.
 *
 * TextUtil.java
 *
 */

package crazy.java.Aetas;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import javax.swing.JLabel;


/**
 *
 * @author Ashish a.k.a Java Crazy
 */

public class TextUtil extends JLabel{
    BufferedImage labelImage = null;
    /** Creates a new instance of TextUtil */
    public TextUtil(){
        super("Aetas");
        setFont(FontUtil.getCompatiableFont(32f));
        setForeground(new Color(42,50,68));
        //setSize(100,300);
        setOpaque(false);
    }
    
    public void paint(Graphics g){
        // Create an image for the button graphics if necessary
        int h=getHeight()-30;
        if (labelImage == null || labelImage.getWidth() != getWidth() ||
                labelImage.getHeight() != h) {
            labelImage = getGraphicsConfiguration().
                    createCompatibleImage(getWidth(), h,Transparency.TRANSLUCENT);
        }
        Graphics glabel =labelImage.getGraphics();
        glabel.setClip(g.getClip());
        
        //  Have the superclass render the label for us
        super.paint(glabel);
        
        Graphics2D g2d  = (Graphics2D)g;
        ReflectionRenderer renderer = new ReflectionRenderer(0.5f, 0.4f, false);
        BufferedImage buffer=renderer.createReflection(labelImage);
        
        // Copy the label's image to the destination graphics, translucently
        g2d.drawImage(labelImage, 0, 0, null);
        new GradientUtils(g2d,0,25,138,25,5,5,GradientUtils.ROUND_RECT_GRADIENT);
        g2d.drawImage(buffer, 0, labelImage.getHeight(), null);
    }
}

